#include "stm32f1xx_hal.h"

#define Lora_Head 0xfe      //帧头
#define Lora_Cmd_Mask 0x80  //命令掩码

// LORA主从机通信命令
enum {
  lora_cmd_call_master = 0x01,  //呼叫
  lora_cmd_cfg                  //配置
};

enum {
  call_cmd_call = 0x01,  //呼叫
  call_cmd_location,     //定位
  call_cmd_cancel,     	 //取消呼叫
};

enum {
  call_cmd_resp_none = 0x00,  //主机应答无
  call_cmd_resp_call = 0x01,  //主机应答呼叫
  call_cmd_resp_add = 0x02,   //主机应答添加
  call_cmd_resp_del = 0x03,   //主机应答删除
  call_cmd_resp_location,     //主机回应定位
  call_cmd_resp_cancel,       //主机回应定位
};

enum {
  cfg_cmd_none = 0x00,
  cfg_cmd_find,              //发现设备
  cfg_cmd_find_resp_bond,    //发现设备回应
  cfg_cmd_find_resp_nobond,  //发现设备回应
  cfg_cmd_find_comp,         //发现设备完成
  cfg_cmd_bond,              //绑定设备
  cfg_cmd_bond_resp,         //绑定设备回应
  cfg_cmd_bond_comp,         //绑定设备完成
};

enum {
  device_st = 0,  // stm32原版
  device_ble_no,  // ble非定位版
  device_ble,     // ble版
  device_cfg,     //配置设备
  device_relay,   //中继设备
};

#define package_len(datalen) (1 + 1 + mac_len + 1 + 1 + datalen + 1)

#define package_min_len 11  //一包数据的最小长度

extern struct process LORA_Process;
void lora_init(void);
void **get_callnum_list(void);
uint8_t get_callnum_cnt(void);
void *get_cur_num(void);
void *get_last_num(void);
void set_cur_num(void *item);
void set_curf_num(void *item);
void remove_num(void *item);
unsigned char remove_callnum(uint16_t num);
void remove_callnum_all(void);
void memb_numcall_free(void *item);
void menb_num_debug(char *fun);
